# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=goffice
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.10.59
_pkgver=GOFFICE_${pkgver//./_}
pkgrel=2
pkgdesc="A GLib/GTK+ set of document-centric objects and utilities. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://gitlab.gnome.org/GNOME/goffice'
license=('spdx:GPL-2.0-only OR GPL-3.0-only')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-atk"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-lasem"
         "${MINGW_PACKAGE_PREFIX}-libgsf"
         "${MINGW_PACKAGE_PREFIX}-librsvg"
         "${MINGW_PACKAGE_PREFIX}-libspectre"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libxslt"
         "${MINGW_PACKAGE_PREFIX}-pango")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             #"${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "intltool")
source=("https://gitlab.gnome.org/GNOME/goffice/-/archive/${_pkgver}/${_realname}-${_pkgver}.tar.bz2"
        "001-no-more-warnings.patch")
sha256sums=('e1379d45c15dddaf46d3fd1f26c4054aabafa9dc02e84d6385d03a2087c39610'
            'dc3c3871f1f09e4052ab8ab11d8c0de6091195c6c186d9b54f78d324ccbaf70f')

prepare() {
  cd "${_realname}-${_pkgver}"

  patch -p1 -i "${srcdir}/001-no-more-warnings.patch"

  autoreconf -fiv
}

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  export lt_cv_deplibs_check_method='pass_all'

  CFLAGS+=" -Wno-implicit-function-declaration" \
  ../"${_realname}-${_pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --enable-shared

  make
}

check() {
  cd "build-${MSYSTEM}"

  make check
}

package() {
  cd "build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}"/${_realname}-${_pkgver}/COPYING* \
    -t "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/
}
